from django.db import models

# Create your models here.

"""
Student :学号，姓名，性别，出生日期，手机号码，邮箱地址，家庭住址，照片
"""


class Student(models.Model):
    GENDER_CHOICES = (
        ("male", "男"),
        ("female", "女")
    )
    sno = models.IntegerField(db_column="SNo", primary_key=True, null=False)  # 学号，不能为空
    name = models.CharField(db_column="Sname", max_length=100, null=False)  # 姓名
    gender = models.CharField(db_column="Gender", max_length=100, default="male", choices=GENDER_CHOICES)  # 性别
    birthday = models.DateField(db_column="Birthday", null=False)  # 出生日期
    mobile = models.CharField(db_column="Mobile", max_length=100)  # 手机号码
    email = models.CharField(db_column="Email", max_length=100, null=True)  # 邮箱地址
    address = models.CharField(db_column="Address", max_length=100)  # 地址
    image = models.CharField(db_column="Image", max_length=200, null=True)  # 照片

    # 在默认的情况下，生成的表名：App_class,如果要自定义，需要使用Class Meta来自定义
    class Meta:
        managed = True  # 自动映射到后台
        db_table = "Student"
        verbose_name = "学生信息"
        verbose_name_plural = verbose_name  # 指明人性化复数时的形式

    def __str__(self):
        return "学号：%s\t 姓名：%s\t 性别：%s" % (self.sno, self.name, self.gender)

    @staticmethod
    def get_title_list():
        return ["学号", "姓名", "性别", "出生日期", "手机号码", "邮箱地址", "住址", "头像"]
